﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _04_流控制
{
    class Program
    {
        static void Main(string[] args)
        {
            //1.if语句
            if (true)
            {
                Console.WriteLine("if语句");
            }
            else
            {
                Console.WriteLine("if语句结束");
            }
            int int_i = 10;

            if (int_i < 9)
            {
                Console.WriteLine("i＜9才输出");
            }
            else if (int_i < 12)
            {
                Console.WriteLine("9<i＜12才输出");
            }

            //2.swith语句
            string string_i = "1";
            switch (string_i)
            {
                case "1":
                    Console.WriteLine("这是1");
                    break;
                case "2":
                    Console.WriteLine("这是2");
                    break;
                default:
                    Console.WriteLine("这是其他数字");
                    break;
            }

            //3.for循环
            Console.WriteLine("----------for循环-----------");
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(i);
            }

            //4.foreach循环：数组循环
            Console.WriteLine("----------foreach循环-----------");
            int[] array_j = {1,2,3,4,5,6,7 };
            foreach (int j in array_j)
            {
                Console.WriteLine(j);
            }

            //5.while循环：先判断后循环
            Console.WriteLine("----------while循环-----------");
            int int_q = 1;
            while (int_q>2)
            {
                Console.WriteLine(int_q);
                int_q --;
            }

            //6.do while循环：先循环后判断
            Console.WriteLine("----------do while循环-----------");
            int int_j = 1;
            do
            {
                Console.WriteLine(int_j);
                int_j--;
            } while (int_j>2);


            Console.ReadKey();
        }
    }
}
